package com.aaa.doctor.controller;

import com.aaa.doctor.service.RegistrationService;
import com.aaa.doctor.vo.RegistrationVo;
import com.aaa.entity.Patient;
import com.aaa.entity.Registration;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.8.0_181
 * @Author ZXJ
 * @Date 2023/3/26 14:34
 * @注释
 */
@RestController
@RequestMapping("/doctor/registration")
public class RegistrationController {
    @Resource
    private RegistrationService registrationService;


    @ApiOperation(value = "分页查询挂号信息")
    @PostMapping("/listRegistration/{currentPage}/{pageSize}")
    public Result<IPage<Registration>> listRegistration(
            @ApiParam(value = "当前页码",required = true) @PathVariable Integer currentPage,
            @ApiParam(value = "每页的个数",required = true) @PathVariable Integer pageSize,
            @RequestBody RegistrationVo registrationVo
    ){
        return registrationService.listRegistration(currentPage,pageSize,registrationVo);
    }


    /**
     * //收费修改状态
     * @param registrationId
     * @return
     */
    @ApiOperation(value = "根据registrationId修改状态（待就诊修改）")
    @PostMapping("/handleCollect/{registrationId}")
    public Result<Integer> handleCollect(@PathVariable String registrationId){
        return registrationService.handleCollect(registrationId);
    }

    @ApiOperation(value = "根据registrationId修改状态（作废）")
    @PostMapping("/handleInvalid/{registrationId}")
    public Result<Integer> handleInvalid(@PathVariable String registrationId){
        return registrationService.handleInvalid(registrationId);
    }

    @ApiOperation(value = "根据registrationId修改状态（退号）")
    @PostMapping("/handleReturn/{registrationId}")
    public Result<Integer> handleReturn(@PathVariable String registrationId){
        return registrationService.handleReturn(registrationId);
    }

    //查询待就诊列表
    @ApiOperation(value = "查询待就诊列表")
    @GetMapping("/queryToBeSeenRegistration/{schedulingType}")
    public Result<List<Registration>> queryToBeSeenRegistration(@PathVariable String schedulingType){
        return registrationService.queryToBeSeenRegistration(schedulingType);
    }
    //查询就诊中列表
    @ApiOperation(value = "查询就诊中列表")
    @GetMapping("/queryVisitingRegistration/{schedulingType}")
    public Result<List<Registration>> queryVisitingRegistration(@PathVariable String schedulingType){
        return registrationService.queryVisitingRegistration(schedulingType);
    }

    //查询就诊完成列表
    @ApiOperation(value = "查询就诊中列表")
    @GetMapping("/queryVisitCompletedRegistration/{schedulingType}")
    public Result<List<Registration>> queryVisitCompletedRegistration(@PathVariable String schedulingType){
        return registrationService.queryVisitCompletedRegistration(schedulingType);
    }

    //接诊 更新挂号状态并插入接诊的医生信息
    //根据挂号id把状态改为就诊中 并把看病医生加上
    @ApiOperation("更改接诊状态")
    @PostMapping("handleVisit/{registrationId}")
    public Result<String> handleVisit(@PathVariable String registrationId){
        return registrationService.handleVisit(registrationId);
    }

//    //新开就诊页面 根据registrationId填充左侧患者信息
//    @ApiOperation(value = "根据挂号id查询患者信息")
//    @PostMapping("/getByRegId/{registrationId}")
//    public Result<Patient> getByRegId(@PathVariable String registrationId){
//        return registrationService.getByRegId(registrationId);
//    }


    @PostMapping("/getRegId/{registrationId}")
    @ApiOperation(value = "收费修改状态")
    public Result<String> getRegId(@PathVariable String registrationId){
        return registrationService.getRegId(registrationId);
    }


    @PostMapping("/wcjz/{registrationId}")
    @ApiOperation(value = "完成就诊修改状态")
    public Result<String> wcjz(@PathVariable String registrationId){
        return registrationService.wcjz(registrationId);
    }

    //获取挂号编号
    @PostMapping("queryDeptNumber/{deptId}")
    @ApiOperation(value = "获取门诊挂号中 根据部门编号获取当前号数")
    public Result queryDeptNumber(@PathVariable Long deptId){
        Integer regNumber = registrationService.getRagNumber(deptId);
        return new Result(200,"查询符合条件的挂号单成功",regNumber);
    }

//    public Result getHaoByDid(@PathVariable Integer id){
//
//    }

}
